package com.zzl.finance.data.feign;

import com.zzl.apidoc.annotation.ApidocOperation;
import com.zzl.apidoc.annotation.ApidocParam;
import com.zzl.finance.data.dto.UserDto;
import com.zzl.finance.data.dto.feign.UserManegeAddDto;
import com.zzl.general.common.apidoc.annotation.ApidocResultKeyValR;
import com.zzl.general.common.apidoc.annotation.ApidocReturnR;
import com.zzl.general.common.apidoc.constants.ResultTypeInR;
import com.zzl.general.common.feign.config.FeignClientsConfig;
import com.zzl.general.common.requestparameter.Ids;
import com.zzl.general.common.serurity.entity.User;
import com.zzl.general.common.utils.Result;
import com.zzl.sharding.user.dto.OrganizationAndUserAddDto;
import com.zzl.sharding.user.dto.UserAddDto;
import com.zzl.sharding.user.entity.UserEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
import java.util.Map;

/**
 * 文件中心的feign接口
 */
@FeignClient(value = "user", configuration = FeignClientsConfig.class)
public interface UserCenterFeign {
    /**
     * 组织机构创建，用户新增，角色关联
     *
     * @param organizationAndUserAddDto 组织角色
     * @return 返回值
     */
    @PostMapping(value = "user/feign/allowAuth/saveOrganizationAndRole")
    Result saveOrganizationAndRole(@RequestBody OrganizationAndUserAddDto organizationAndUserAddDto);

    /**
     * 创建用户信息
     *
     * @param user 用户实体
     * @return 用户实体
     */
    @PostMapping("user/feign/allowAuth/saveUser")
    Result saveUser(@ApidocParam(name = "保存的用户表对象值", required = true) @RequestBody UserAddDto user);

    /**
     * 创建多个用户信息
     *
     * @param user 用户实体
     * @return 用户实体
     */
    @PostMapping("user/feign/saveUserList")
    Result saveUserList(@ApidocParam(name = "保存的用户表对象值", required = true) @RequestBody UserDto user);

    /**
     * 查询企业管理员的 名称 电话 邮箱
     *
     * @param enterpriseIds 企业id 结合
     * @return 企业管理员的数据
     */
    @PostMapping("user/feign/getBatchEnterpriseManager")
    List<UserEntity> getAdminInfo(@RequestBody List<String> enterpriseIds);



    /**
     * 查询企业用户信息
     *
     * @param enterpriseId 企业id 结合
     * @return 企业管理员的数据
     */
    @GetMapping("user/feign/listByEnterpriseId/{enterpriseId}")
    List<UserEntity> listByEnterpriseId(@PathVariable("enterpriseId") String enterpriseId);

    /**
     * 用户ids获取用户信息
     *
     * @return
     */
    @PostMapping("user/feign/getUserInfo/mapByIds")
    Map<Integer, UserEntity> mapByIds(@RequestBody Ids ids);

    @GetMapping("user/feign/allowAuth/getUserByEnterpriseId/{enterpriseId}")
    @ApidocOperation(description = "根据企业id查询管理员信息", operationId = "user/feign/getUserByEnterpriseId/enterpriseId")
    @ApidocReturnR(otherkv = {
            @ApidocResultKeyValR(resultType = ResultTypeInR.TYPE_OBJECT, key = "data", valueClass = UserEntity.class)
    })
    Result getUserByEnterpriseId(@ApidocParam(name = "enterpriseId", description = "企业id", required = true) @PathVariable("enterpriseId") String enterpriseId);


    @PostMapping("user/feign/saveManegeUser")
    @ApidocOperation(description = "保存管理员信息（包括部门的创建）", operationId = "user/feign/allowAuth/saveUser")
    Result saveManegeUser(@ApidocParam(name = "保存的用户表对象值", required = true) @RequestBody UserManegeAddDto manegeAddDto);
}
